package com.km.gulimall.order.service.impl;

import com.km.gulimall.order.entity.OrderReturnReasonEntity;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.km.common.utils.PageUtils;
import com.km.common.utils.Query;

import com.km.gulimall.order.dao.OrderItemDao;
import com.km.gulimall.order.entity.OrderItemEntity;
import com.km.gulimall.order.service.OrderItemService;


@Service("orderItemService")
public class OrderItemServiceImpl extends ServiceImpl<OrderItemDao, OrderItemEntity> implements OrderItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrderItemEntity> page = this.page(
                new Query<OrderItemEntity>().getPage(params),
                new QueryWrapper<OrderItemEntity>()
        );

        return new PageUtils(page);
    }

    /*
    *  queues：声明需要监听的所有队列
    *
    *  Queue: 可以有很多人来监听。只要收到消息，队列就会删除消息，而且只会有一个人收到此消息
    *
    * */
    @RabbitListener(queues = {"hello-java-queue"})
    public void recieveMessage(Message message, OrderReturnReasonEntity content){
        //拿到主体内容
        byte[] body = message.getBody();
        //拿到消息头属性信息
        MessageProperties messageProperties = message.getMessageProperties();
        System.out.println("接收到信息。。。内容："+message+"==》内容："+content);
    }

}